package io.renren.modules.yckj.common;

import cn.hutool.core.thread.threadlocal.NamedThreadLocal;
import io.renren.modules.yckj.dto.UserDTO;

public class ThreadLocalUtil {
    private static final ThreadLocal<UserDTO> USER = new NamedThreadLocal<>("userId");

    public static void setUser(UserDTO userDTO) {
        USER.set(userDTO);
    }

    public static UserDTO getUser() {
        return USER.get();
    }

    public static Long getUserId() {
        return USER.get().getId();
    }

    public static String getOpenid() {
        return USER.get().getOpenid();
    }

    public static String getUserName() {
        return USER.get().getUsername();
    }
}